﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PROJECT_BOMBER.BLL;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using PROJECT_BOMBER.BLL.Events;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;

namespace PROJECT_BOMBER.BLL.States
{
    public class GameOverState : GameState
    {
        internal Texture2D img;
        internal MenuButton button1;
        internal MouseEvent mouseEvent;
        SoundEffect Over;

        public override void Initialize()
        {
            Over = Globals.Content.Load<SoundEffect>("fin");
            img = Globals.Content.Load<Texture2D>("gameOver");
            button1 = new MenuButton(new Vector2((Globals.GDM.PreferredBackBufferWidth - 300), Globals.GDM.PreferredBackBufferHeight), Globals.Content.Load<Texture2D>("bouton"), Globals.Content.Load<Texture2D>("bouton"), new Microsoft.Xna.Framework.Rectangle());
            Globals.Game.IsMouseVisible = true;
            mouseEvent = new MouseEvent();
            MediaPlayer.Stop();
            Over.Play();
        }

        public override void Update(float deltatime)
        {
            if (mouseEvent.UpdateMouse() == true)
            {
                Globals.Game.IsMouseVisible = false;
                Globals.GameStateStack.Set(new LoadState(new PlayState()));
            }

            KeyboardState ks = Keyboard.GetState();
            if (ks.IsKeyDown(Keys.S))
            {
                Globals.Game.IsMouseVisible = false;
                Globals.GameStateStack.Set(new LoadState(new PlayState()));
            }
        }

        public override void Draw()
        {

            Globals.SpriteBatch.Begin();

            // Globals.SpriteBatch.DrawString(Globals.ArialFont, WelcomeText, WelcomeTextPosition, Color.Red);

            Globals.SpriteBatch.Draw(img, new Vector2((Globals.GDM.PreferredBackBufferWidth - 972) / 2, (Globals.GDM.PreferredBackBufferHeight - 685) / 2), Color.White);

            button1.DrawButton(Globals.SpriteBatch);

            Globals.GDM.GraphicsDevice.Clear(Color.Black);
            Globals.SpriteBatch.End();
        }

        public override void Load()
        {
        }

        public override void Unload()
        {
            throw new NotImplementedException();
        }
    }
}
